package ch.unisi.inf.java.project.riskbami.model;


/**
 * AttackCommand is an extension of GenericCommand.
 * Provide the implementation of a commands that is responsible to attack
 * 
 * @author minellir@lu.unisi.ch
 * @author babazadm@lu.unisi.ch
 */
public final class AttackCommand extends GenericCommand {

    private final Country source;
    private final Country destination;
    private final Player player;

    /**
     * The constructor for the class AttackCommand
     * 
     * @param game The actual game
     * @param src The country from which the attack starts
     * @param dest The country in which the attack is made 
     */
    public AttackCommand(final Game game, final Country src, final Country dest){
        super(game);
        source = src;
        destination = dest;
        this.player = game.getCurrentPlayer();
    }
    
    /**
     * canExecute verify whether the AttackCommand could be executed
     * 
     * @return boolean
     */
    public final boolean canExecute() {
        if(game.getTurnPhase() == 2) {
            return true;
        }
        else return false;
    }
    
    /**
     * execute is responsible to execute the given AttackCommand.
     */
    public final void execute(){
        player.attack(source, destination);
    }

}
